package org.jypj.dev.task;

import org.jypj.dev.listener.SessionListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.Set;

/**
 * Created by ChenYu on 2017-03-27.
 */
@Component
public class SessionTask {

    /**
     * 每隔5分钟判断一次失效的连接
     */
   /* @Scheduled(cron = "0 0/5 0 * * ?")
    public void checkInvalidConn() {
        Set<String> strings = SessionListener.timeMap.keySet();
        for (String string : strings) {
            Long aLong = SessionListener.timeMap.get(string);
            long currentTime = new Date().getTime();
            boolean check = (currentTime - aLong) > 5 * 60 * 1000;
            if (check) {
                //如果连接超过了五分钟，就强制退出
                SessionListener.forceLogoutRealSessionMapUser(string);
            }
        }
    }*/
}
